//
//  NearbyPhotoCollectionViewCell.m
//  HappyTrip
//
//  Created by GeminyXC on 15-3-27.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "NearbyPhotoCollectionViewCell.h"


#import "NearbyPicCollectionViewCell.h"
//图片第三方
//#import "UIImageView+WebCache.h"

@implementation NearbyPhotoCollectionViewCell




- (void)dealloc
{
    [_imageView release];
    [_trip_nameLabel release];
    [_textView release];
//    [_textLabel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageView = [[UIImageView alloc] init];
        self.imageView.contentMode = UIViewContentModeScaleAspectFit;
        [self.contentView addSubview:_imageView];
        [_imageView release];
        
        self.trip_nameLabel = [[UILabel alloc] init];
        self.trip_nameLabel.textColor = [UIColor whiteColor];
        self.trip_nameLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_trip_nameLabel];
        [_trip_nameLabel release];
        

        
        self.textView = [[UITextView alloc] init];
        self.textView.textColor = [UIColor lightGrayColor];
        self.textView.backgroundColor = [UIColor clearColor];
//        self.textView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
        self.textView.font = [UIFont systemFontOfSize:12];
        self.textView.userInteractionEnabled = NO;
        [self.contentView addSubview:_textView];
        [_textView release];
        
        
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    CGFloat width = layoutAttributes.bounds.size.width;
    CGFloat height = layoutAttributes.bounds.size.height;
    
    self.imageView.frame = CGRectMake(0, 0 - 30, width, height);
    
    self.trip_nameLabel.frame = CGRectMake(0, height - 50 - 30, width, 25);
    
    self.textView.frame = CGRectMake(5, 5, width - 10, height);
    
    
}

//在set方法中赋值
- (void)setNearbyPicInfo:(NearbyPicObject *)nearbyPicInfo
{
    if (_nearbyPicInfo != nearbyPicInfo) {
        [_nearbyPicInfo release];
        _nearbyPicInfo = [nearbyPicInfo retain];
    }
    
    
    self.imageView.image = nil;
    NSString *picStr = self.nearbyPicInfo.photo;
    NSURL *picUrl = [NSURL URLWithString:picStr];//加个占位图
    [self.imageView setImageWithURL:picUrl placeholderImage:[UIImage imageNamed:@"picLoading.png"]];
    
    self.trip_nameLabel.text = self.nearbyPicInfo.trip_name;
    self.textView.text = self.nearbyPicInfo.text;
    
}




@end
